package first1

/**
  * description
  *
  * @author Llx
  * @version v1.0.0
  * @since 2018/10/8
  */
class HanShuShiBianChengTest {


  /**
    * 定义一个函数，接受一个函数，一个int变量   函数的实现是，调用传进了的匿名函数
    * @param f
    * @param x
    * @return
    */
  def f1(f:(Int)=>Int,x:Int) =f(x)

  def f2(x:Int):Int = {
    println( x*2)
    x*2
  }

  def apply: HanShuShiBianChengTest = new HanShuShiBianChengTest()
}

object HanShuShiBianChengTest extends App{
   val v = new HanShuShiBianChengTest()
  def f2(x:Int):Int = {
    println( x*2)
    x*2
  }
  private val ints = Array(1,2,3)
  private val unit = ints.foreach(e => {
    v.f1(v.f2, e)
  })
  println(unit)
}